package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldRecruitPlanDto;
import com.cleaningcloud.cld.domain.vo.CldRecruitPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.api.domain.CldRecruitPlan;
import com.cleaningcloud.cld.service.ICldRecruitPlanService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 招聘计划Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/recruitPlan")
public class CldRecruitPlanController extends BaseController
{
    @Autowired
    private ICldRecruitPlanService cldRecruitPlanService;

    /**
     * 查询招聘计划列表
     */
    @RequiresPermissions("cld:recruitPlan:list")
    @GetMapping("/list")
    public TableDataInfo list(CldRecruitPlanDto cldRecruitPlan)
    {
        startPage();
        List<CldRecruitPlanVo> list = cldRecruitPlanService.selectCldRecruitPlanList(cldRecruitPlan);
        return getDataTable(list);
    }



    /**
     * 获取招聘计划详细信息
     */
    @RequiresPermissions("cld:recruitPlan:query")
    @GetMapping(value = "/{recruitPlanId}")
    public AjaxResult getInfo(@PathVariable("recruitPlanId") Long recruitPlanId)
    {
        return success(cldRecruitPlanService.selectCldRecruitPlanByRecruitPlanId(recruitPlanId));
    }


    /**
     * 获取招聘计划详细信息
     */
    @GetMapping(value = "/getInfoByRecruitPhone/{recruitPhone}")
    public AjaxResult getInfoByRecruitPhone(@PathVariable("recruitPhone") String recruitPhone)
    {
        return success(cldRecruitPlanService.selectCldRecruitPlanByRecruitPhone(recruitPhone));
    }

    /**
     * 新增招聘计划
     */
    @RequiresPermissions("cld:recruitPlan:add")
    @Log(title = "招聘计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldRecruitPlan cldRecruitPlan)
    {
        return toAjax(cldRecruitPlanService.insertCldRecruitPlan(cldRecruitPlan));
    }

    /**
     * 修改招聘计划
     */
    @RequiresPermissions("cld:recruitPlan:edit")
    @Log(title = "招聘计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldRecruitPlan cldRecruitPlan)
    {
        return toAjax(cldRecruitPlanService.updateCldRecruitPlan(cldRecruitPlan));
    }

    /**
     * 删除招聘计划
     */
    @RequiresPermissions("cld:recruitPlan:remove")
    @Log(title = "招聘计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recruitPlanIds}")
    public AjaxResult remove(@PathVariable Long[] recruitPlanIds)
    {
        return toAjax(cldRecruitPlanService.deleteCldRecruitPlanByRecruitPlanIds(recruitPlanIds));
    }
}
